<extend name="Layout:layout_list" />
<block name="body_content_block">
    <form action="{:AddonU('CtiTester/dial_save')}" method="post">
        <ul>
            <li>
                <label>呼叫号码：</label>
                <input type="text" name="phoneNumber" placeholder="请输入呼叫号码" title="请填写呼叫号码!" required />
            </li>
            <li>
                <label>中继名称：</label>
                <select name="trunkName" title="请选择中继名称" required data-url="{:AddonU('Trunk/get_json')}"></select>
                <input type="text" name="callerNo" title="请填写主叫号码" placeholder="请填写主叫号码" style="display: none;" />
                <input type="hidden" name="regMode" />
            </li>
            <li class="checkboxs">
                <label>流程名称：</label>
                <input type="text" name="context" placeholder="请输入流程名称" title="请填写流程名称!" value="xcall" required />
            </li>
            <li>
                <button type="submit" class="button">立即呼叫</button> <a href="{:AddonU('CtiTester/index')}" class="easyui-linkbutton">返回</a>
            </li>
        </ul>
    </form>
</block>
<block name="body_after_block">
<script type="text/javascript">
    ajax_load_options({selector:'select[name="trunkName"]', def_option: '请选择中继名称'});
    // 中继号码
    $('select[name="trunkName"]').change(function() {
        var txt = $(this).find('option:selected').text();
        set_trunkName((txt.indexOf('(ip|') > 0) ? 'ip' : 'register');
    });
    function set_trunkName(regMode) {
        if (regMode == 'ip') {
            $('input[name="regMode"]').val('ip');
            $('input[name="callerNo"]').show();
        } else {
            $('input[name="regMode"]').val('register');
            $('input[name="callerNo"]').hide();
        }
    }
</script>
</block>